<?php defined('IN_PHPCMS') or exit('Access Denied'); ?><?php include template('member','header'); ?>
<div id="main"> <?php include template("member","left"); ?>
  <div id="right">
    <p id="position"><strong>当前位置：</strong><a href="">首页</a><a href="<?php echo $M['url'];?>member.php">我的广告</a><a>广告统计</a><?php echo $info_ads['adsname'];?></p>
    
<form name='myform' action='<?php echo $M['url'];?>stat.php' method='get'>
    <table cellpadding="0" cellspacing="1" class="table_form">
      <tr>
        <th>按时间段统计：</th><td><input type='hidden' name='adsid' value='<?php echo $adsid;?>'><input type='hidden' name='type' value='1'> <?php echo form::date("from");?> - <?php echo form::date('end');?> <input type="submit" value="查询"></td>
      </tr>
    </table>
</form>
    <div class="tag_menu">
    <ul>
          <li><a href="<?php echo $M['url'];?>stat.php?type=1&adsid=<?php echo $adsid;?>">按所属地域排序</a></li>
          <li><a href="<?php echo $M['url'];?>stat.php?type=2&adsid=<?php echo $adsid;?>">按访问者IP排序</a></li>
          <li><a href="<?php echo $M['url'];?>stat.php?type=3&adsid=<?php echo $adsid;?>">按访问用户排序</a></li>
          <li><a href="<?php echo $M['url'];?>stat.php?type=4&adsid=<?php echo $adsid;?>">按访问页面排序</a></li>
        </ul>
    </div>
<table cellpadding="0" cellspacing="1" class="table_list">
      <?php if($type==1) { ?>
      <tr>
        <th width="30%">所属地域</th>
        <th width="69%" colspan="3">展示次数</th>
      </tr>
      <?php if(is_array($states[1])) foreach($states[1] AS $i => $stat) { ?>
      <tr>
        <td><?php echo $stat['area'];?></td>
        <td colspan="3"><?php echo $stat['num'];?></td>
      </tr>
      <?php } ?>
  <?php } elseif ($type==3) { ?>
      <tr>
        <th width="24%">用户名</th>
        <th colspan="3">展示次数</th>
      </tr>
      <?php if(is_array($states[1])) foreach($states[1] AS $i => $stat) { ?>
      <tr>
        <td><?php echo $stat['username'];?></td>
        <td colspan="3"><?php echo $stat['num'];?></td>
      </tr>
      <?php } ?>
      <?php } elseif ($type==4) { ?>
      <tr>
        <th width="85%">展示页面</th>
        <th width="15%" colspan='3'>展示次数</th>
      </tr>
      <?php if(is_array($states[1])) foreach($states[1] AS $i => $stat) { ?>
      <tr>
        <td style="text-align:left"><a href="<?php echo $stat['referer'];?>" target="_blank"><?php echo str_cut($stat[referer], 100);?></a></td>
        <td colspan='3'><?php echo $stat['num'];?></td>
      </tr>
      <?php } ?>
      <?php } else { ?>
      <tr>
        <th>IP</th>
        <th>所属地域</th>
        <th>展示时间</th>
        <th>展示次数</th>
      </tr>
      <?php if(is_array($states[1])) foreach($states[1] AS $i => $stat) { ?>
      <tr>
        <td><?php echo $stat['ip'];?></td>
        <td><?php echo $stat['area'];?></td>
        <td><?php echo date('Y-m-d H:i', $stat[clicktime]);?></td>
        <td><?php echo $stat['num'];?></td>
      </tr>
      <?php } ?>
      <?php } ?>
    </table>
  </div>
</div>
<?php include template('phpcms', 'footer'); ?>